package web.testBIO;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Client {
	private static String ip = "127.0.0.1";

	private static int port = 8888;

	public static void main(String[] args) throws IOException {
		Socket socket =null;
		try {
			 socket = new Socket(ip, port);
			BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

			// 向服务器端发送数据
			out.println("我是client...1" + Thread.currentThread().getName());
			out.println("我是client...2" + Thread.currentThread().getName());
			out.println("我是client...13" + Thread.currentThread().getName());
			out.println("我是client...4" + Thread.currentThread().getName());
			out.println("我是client...5" + Thread.currentThread().getName());
			out.flush();
			socket.shutdownOutput();
			String s =null;
			while ((s = in.readLine()) != null) {
				System.out.println("我是客户端，服务器说：" + s);
			}
			socket.shutdownInput();
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			if(socket!=null) {
				socket.close();
			}
		}

	}

}
